﻿using System;
using UnityEngine;

// Token: 0x02000138 RID: 312
[DisallowMultipleComponent]
[AddComponentMenu("RVP/C#/Hover/Hover Steer", 2)]
public class HoverSteer : MonoBehaviour
{
	// Token: 0x060005AD RID: 1453 RVA: 0x0002CD5E File Offset: 0x0002AF5E
	private void Start()
	{
		this.tr = base.transform;
		this.vp = (VehicleParent)F.GetTopmostParentComponent<VehicleParent>(this.tr);
	}

	// Token: 0x060005AE RID: 1454 RVA: 0x0002CD84 File Offset: 0x0002AF84
	private void FixedUpdate()
	{
		float f = this.vp.localVelocity.z / this.steerCurveStretch;
		float num = this.steerCurve.Evaluate(Mathf.Abs(f));
		this.steerAmount = this.vp.steerInput * num;
		foreach (HoverWheel hoverWheel in this.steeredWheels)
		{
			hoverWheel.steerRate = this.steerAmount * this.steerRate;
		}
	}

	// Token: 0x060005AF RID: 1455 RVA: 0x0002CE08 File Offset: 0x0002B008
	private void Update()
	{
		if (this.rotate)
		{
			this.steerRot = Mathf.Lerp(this.steerRot, this.steerAmount * this.maxDegreesRotation + this.rotationOffset, this.steerRate * 0.1f * Time.timeScale);
			this.tr.localEulerAngles = new Vector3(this.tr.localEulerAngles.x, this.tr.localEulerAngles.y, this.steerRot);
		}
	}

	// Token: 0x0400081C RID: 2076
	private Transform tr;

	// Token: 0x0400081D RID: 2077
	private VehicleParent vp;

	// Token: 0x0400081E RID: 2078
	public float steerRate = 1f;

	// Token: 0x0400081F RID: 2079
	private float steerAmount;

	// Token: 0x04000820 RID: 2080
	[Tooltip("Curve for limiting steer range based on speed, x-axis = speed, y-axis = multiplier")]
	public AnimationCurve steerCurve = AnimationCurve.Linear(0f, 1f, 30f, 0.1f);

	// Token: 0x04000821 RID: 2081
	[Tooltip("Horizontal stretch of the steer curve")]
	public float steerCurveStretch = 1f;

	// Token: 0x04000822 RID: 2082
	public HoverWheel[] steeredWheels;

	// Token: 0x04000823 RID: 2083
	[Header("Visual")]
	public bool rotate;

	// Token: 0x04000824 RID: 2084
	public float maxDegreesRotation;

	// Token: 0x04000825 RID: 2085
	public float rotationOffset;

	// Token: 0x04000826 RID: 2086
	private float steerRot;
}
